local skel = fk.CreateSkill {
  name = "efengqi__lieren",
}

Fk:loadTranslationTable{
  ["efengqi__lieren"] = "烈刃",
  [":efengqi__lieren"] = "当你使用伤害牌指定目标后，你可以与一名角色拼点，若你赢且：对方为目标，你获得其一张牌，对方不为目标，其成为额外目标。",
  ["#efengqi__lieren-choose"] = "烈刃：你可以选择一名角色，与其拼点",

  ["$efengqi__lieren1"] = "亮兵器吧。",
  ["$efengqi__lieren2"] = "尝尝我飞刀的厉害！",
}

skel:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.firstTarget and
      data.card.is_damage_card and not player:isKongcheng()
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function (p) return player:canPindian(p) end)
    if #targets == 0 then return false end
    local tos = player.room:askToChoosePlayers(player, {
      min_num = 1, max_num = 1, targets = targets, skill_name = skel.name,
      prompt = "#efengqi__lieren-choose",
    })
    if #tos > 0 then
      event:setCostData(self, {tos = tos})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local pindian = player:pindian({to}, skel.name)
    if pindian.results[to].winner == player then
      if table.contains(data.use.tos, to) then
      if player.dead or to.dead or to:isNude() then return end
        local card = room:askToChooseCard(player, {
          skill_name = skel.name,
          target = to,
          flag = "he",
        })
        room:obtainCard(player, card, false, fk.ReasonPrey, player, skel.name)
      elseif not data.from:isProhibited(to, data.card) then
        room:doIndicate(player, {to})
        data:addTarget(to)
      end
    end
  end,
})

return skel
